<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:opml="http://www.opml.org/2002/Attributes"
                exclude-result-prefixes="opml"
                xmlns="http://www.opml.org/2002/Attributes"
                xmlns:date="http://exslt.org/dates-and-times"
                xmlns:set="http://exslt.org/sets"
                xsl:extension-element-prefixes="date set"
                version="1.0">
  <xsl:output method='xml' indent='yes'/>
  <xsl:strip-space elements="*" />

  <!-- Copyright (c) 2009 -->
  <!-- Author: King-On Yeung (koyeung@gmail.com) -->
  <!-- Homepage: http://koyeung.blogspot.com/ -->

  <!-- match topmost node -->
  <xsl:template match="opml:opml">
    <opml version="1.0">
      <xsl:apply-templates  />
    </opml>
  </xsl:template>

  <!-- remove previous dateModified -->
  <xsl:template match="opml:head/opml:dateModified" />

  <!-- preserve others -->
  <xsl:template match="opml:head/*">
    <xsl:copy-of select="." />
  </xsl:template>

  <!-- update dateModified -->
  <xsl:template match="opml:head">
    <head>
      <xsl:apply-templates />
      <dateModified><xsl:value-of select="date:date-time()" /></dateModified>
    </head>
  </xsl:template>

  <xsl:template match="opml:body">
    <body>
      <xsl:apply-templates />
    </body>
  </xsl:template>

  <!-- main logic: include only those leading to feed elements -->
  <xsl:template match="opml:outline[.//@type]" >
    <outline>
      <xsl:copy-of select="@*" />
      <xsl:apply-templates /> 
    </outline>
  </xsl:template>

</xsl:stylesheet>
